<!--7政府部门 6 行业协会 -->
<div class="tab-pane fade" id="tab-group">
  <div class="panel-body">
		<div class="form-horizontal">
		  <fieldset>
		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">单位名称</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="company_name" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">组织机构代码</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="group_code" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">联系人</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="contact_person" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">联系人电话</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="contact_number" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="select" class="col-xs-3 control-label">注册地址</label>
		      <div class="col-xs-6">

		        <select class="form-control select_size selects" name="province" id="province">
		          <option value="-1">请选择</option>
		          @foreach ($province as $value)
		          <option value="<%$value['area_id']%>"><%$value['area_name']%></option>
		          @endforeach
		        </select>
		        <select class="form-control select_size selects" name="city" id="city">
		          <option value="-1">请选择</option>
		        </select>
		        <select class="form-control select_size selects" name="area" id="area">
		          <option value="-1">请选择</option>
		        </select>
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">详细地址</label>
		      <div class="col-xs-6">
			  	<input class="form-control input_size" name="address" id="inputEmail" placeholder="" type="text">
			  </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">邮政编码</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="zcode" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">传真</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="fax" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="inputEmail" class="col-xs-3 control-label label_size">联系人邮箱</label>
		      <div class="col-xs-6">
		        <input class="form-control input_size" name="email" id="inputEmail" placeholder="" type="text">
		      </div>
		    </div>


		    <div class="form-group">
		    	<label class="col-xs-3 control-label no_padding_right">LOGO:</label>
		    	<div class="col-xs-6">
		    		<input type="file" name="imgFile" class="uploadImage">
		    		<input type="hidden" name="logo" class="hiddenName">
		    		<span class="fileName"></span>
		    	</div>
		    </div>

		    <div class="form-group">
		    	<label for="inputEmail" class="col-xs-3 control-label no_padding_right">营业执照副本:</label>
		    	<div class="col-xs-6">
		    		<input type="file" name="imgFile" class="uploadImage">
		    		<input type="hidden" name="regist_copy" class="hiddenName">
		    		<span class="fileName"></span>
		    	</div>
		    </div>

		    <div class="form-group">
		      <label class="col-xs-3 control-label no_padding_right">描述:</label>
		      <div class="col-xs-6">
		        <textarea class="form-control text_size" name="description" rows="3"></textarea>
		        <span class="help-block"></span>
		      </div>
		    </div>

		    <div class="form-group">
		      <label for="textArea" class="col-xs-3 control-label label_size">简介</label>
		      <div class="col-xs-9">
			    	<div id="group" name="group" style="height:500px;"></div>
		      </div>
		    </div>

		    <div class="form-group">
		      <div class="col-xs-12 text-center">
		        <button type="submit" id="sub" class="btn btn-primary">保存修改</button>
		      </div>
		    </div>
		  </fieldset>
		</div>
	</div>
</div>


<script type="text/javascript">
var ue = UE.getEditor('group');
var  que = "que";
var isAsync;

var loadGroup = true;

$("#showGroup").click(function(){
	if(loadGroup){
		$.getq(que, "get_user_group", {uid : uid}, function (data){
			if(data.success){
				$.each(data.data, function (k, v){
					$("#tab-group input[type='text'][name="+k+"]").val(v);
					$("#tab-group input[type='hidden'][name="+k+"]").val(v);
				})
				$("#tab-group input[type='radio'][name='enterprice_char'][value="+data.data.enterprice_char+"]").attr("checked", "checked");

				$("#tab-group textarea[name='description']").val(data.data.description);
				ue.ready(function(){
				       ue.setContent(decodeURIComponent(data.data.induction));
				   });
				isAsync = false;
				$("#tab-group select[name='province']").val(data.data.province);
				$("#tab-group select[name='province']").change();
				$("#tab-group select[name='city']").val(data.data.city);
				$("#tab-group select[name='city']").change();
				$("#tab-group select[name='area']").val(data.data.area);
				isAsync = true;
				loadGroup = false;
			}
		})
	}
})



$(".uploadImage").AjaxFileUpload({
	path : url + "upload",
	onComplete : function(filename){
			$(this).siblings(".hiddenName").val(filename.filename);
			$(this).siblings(".fileName").html(filename.filename);
		}
	});

$(".selects").change(function(){
	_this = $(this);
	var pid = $(this).val();
	$.ajax({
		url : url + 'address/getarea',
		data : {pid : pid},
		type : "get",
		async: isAsync,
		success:function(data){
			var str = '<option value="-1">请选择</option>';
			$.each(data.area,function(k, v){
				str += '<option value="'+v.area_id+'">'+v.area_name+'</option>';
			})
			_this.next("select").html(str).next("select").html('<option value="-1">请选择</option>');
		}
	})
})


var groupData = {};
$("#tab-group #sub").click(function(){
	$.each($("#tab-group input"), function (k, v){
		groupData[$(v).attr("name")] = $(v).val();
	})
	$.each($("#tab-group select"), function (k, v){
		groupData[$(v).attr("name")] = $(v).val();
	})
	groupData["induction"] = encodeURIComponent(ue.getContent());
	groupData["uid"] = uid;
	groupData["description"] = $("#tab-group textarea[name='description']").val();
	groupData["enterprice_char"] = $("#tab-group input[name='enterprice_char']:checked").val();

	$.post("update_group", groupData, function (data){
		if(data.success){
			success("", "修改成功!");

		}

	})

})

</script>